<%@ page contentType="text/html;charset=UTF-8" language="java" isELIgnored="false" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title>用户列表</title>
    <script type="text/javascript" src="/js/jquery.min.js"></script>

</head>

<body>
<button id="btn2">全部的用户列表哦</button>
<table class="tab2" width="100%">
    <tr>

        <th>id</th>

        <th>名字</th>
        <th>密码</th>
    </tr>

    <tbody id="tbodydata">

    </tbody>
</table>
</body>


</html>
<script>
    $(function () {

        $("#btn2").on("click", function () {

            //提交表单
            $.ajax({
                url: "/user/userlist",
                type: "get",
                dataType: "json",
                data: {

                },
                success: function (data) {
                    var str="";
                    for (var i in data) {
                        var id =  data[i].id;
                        str += "<tr>" +

                            "<td align='center'>" + data[i].id + "</td>" +
                            "<td align='center'>" + data[i].name + "</td>" +
                            "<td align='center'>" + data[i].password + "</td>" +
                            "<td align='center'>" +   "<a href='/user/delete/?id='>删除</a>" + "</td>" +

                        "</tr>";
                    }

                    document.getElementById("tbodydata").innerHTML=str;

                }
            })
        })
    })
</script>